package com.jiepu.daily.corejava.advanceed.part7io.day0810;

import org.junit.Test;

import java.io.*;
import java.nio.charset.StandardCharsets;

/**
 * @Description:
 * @author: xinjie
 * @date: 2020/8/10  15:10
 */
public class EncodingConversionDemo {
	public static void main(String[] args) {
		String path = "src/com/jiepu/daily/advanceed/part7_io/io_test/poem.txt";

	}

	@Test
	public void conversion1() throws IOException {
		// UTF-8 -> GBK
		String sourcepath = "src/com/jiepu/daily/advanceed/part7_io/io_test/poem.txt";
		String targetpath = "src/com/jiepu/daily/advanceed/part7_io/io_test/poem-2.txt";

		FileInputStream fis = new FileInputStream(sourcepath);
		FileOutputStream fos = new FileOutputStream(targetpath);

		InputStreamReader  isr = new InputStreamReader(fis, StandardCharsets.UTF_8);
		OutputStreamWriter osw = new OutputStreamWriter(fos, "GBK");

		char[] buf = new char[64];
		int len = -1;
		while ((len = isr.read(buf)) != -1){
			osw.write(buf,0,len);
		}
	}

	@Test
	public void conversion2(){

		

	}


}
